<span class="glyphicon glyphicon-map-marker" aria-hidden="true" style="position: absolute;top: 23px;">
    <span>系统</span> /
    <span>系统权限</span> /
    <span>添加管理权限</span>
</span>
<row>
    <div class="col-md-12" style="margin-top: 37px;">
        <form class="form-horizontal layui-form" id="form">
            <div class="form-group">
                <label for="name" class="col-md-2 control-label">
                    <div class="text-center">管理权限</div>
                </label>
                <div class="col-md-7">
                    <input type="text" class="form-control" id="name" name="name"
                           placeholder="管理权限">
                </div>
            </div>
            <div class="form-group">
                <label for="name" class="col-md-2 control-label">
                    <div class="text-center">选择操作权限</div>
                </label>
                <div class="col-md-9">
                    <table class="table" width="100%" border="1">
                        {volist name="permission" id="vo"}
                        <tr>
                            <td colspan="2" style="text-align: left;vertical-align: middle;">{$vo.title}</td>
                        </tr>
                        {volist name="$vo.list" id="title"}
                        <tr>
                            <td width="20%" style="text-align: right;vertical-align: middle;">{$title.title}</td>
                            <td style="text-align: left;vertical-align: middle;">
                                {volist name="$title.list" id="v"}
                                {if condition="$vo.title == '系统功能'"}
                                <!--<label class="checkbox-inline">-->
                                <input type="checkbox" name="Jurisdiction[]" lay-skin="primary" checked title="{$v.title}" value="{$v.url}">
                                <!--</label>-->
                                {else /}
                                <!--<label class="checkbox-inline">-->
                                <input type="checkbox" name="Jurisdiction[]" lay-skin="primary" title="{$v.title}" value="{$v.url}">
                                <!--</label>-->
                                {/if}
                                {/volist}
                            </td>
                        </tr>
                        {/volist}
                        {/volist}
                    </table>

                </div>
            </div>
            <div class="form-group save-btn" style="">
                <button type="button" onclick="Add()" >添加</button>
                <button type="button" onclick="javascript:history.back(-1);return false;" style="background: red;">取消</button>
            </div>
        </form>
    </div>
</row>
<style type="text/css">
    .layui-unselect{
        margin-left: 4px;
        margin-top: 15px;
    }
</style>
<script src="__JS__/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function() {
        var form = layui.form
                , layer = layui.layer;
    });
</script>
<script type="text/javascript">
    function Add() {
        var name = $("input[id='name']").val();
        if(name == ""){
            layer.msg("请输入管理权限");
            return false;
        }
        var obj = document.getElementsByName("Jurisdiction");
        var s='';
        for(var i=0; i<obj.length; i++){
            if(obj[i].checked){
                s+=obj[i].value+'|'; //如果选中，将value添加到变量s中
            }
        }
        var jurisdiction = s;
        var json = {name:name,jurisdiction:jurisdiction};
        $.ajax({
            type:"POST",
            url:"{:url('Admin/UserType/Add')}",
            data:json,
            success:function (res) {
                console.log(res);
                layer.msg(res);
                if(res == "添加成功"){
                    setTimeout("UserType()",3000);
                }
            }
        });
    }
    function UserType() {
        window.location.href = "{:url('Admin/UserType/index')}";
    }
</script> 